package com.cfgj.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cfgj.entity.Image;
import com.cfgj.entity.Projects;
import com.cfgj.mapper.ProjectsMapper;
import com.cfgj.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ProjectServiceImpl implements ProjectService {
    public static Integer CURRENT_PAGE = 1;
    public static Integer PAGE_SIZE = 10;
    @Autowired
    private ProjectsMapper projectsMapper;

    @Override
    public IPage<Projects> findPageList(Integer page, Integer size,Integer step) {
            if (page != null) {
                CURRENT_PAGE = page;
            }
            if (size != null) {
                PAGE_SIZE = size;
            }
            Map<String ,Object> map= new HashMap<String ,Object>();
            QueryWrapper<Projects> bussinessQueryWrapper= new QueryWrapper<Projects>()
                    .eq("step",step);

            IPage<Projects> pageFilm = projectsMapper.selectPage(
                    new Page<Projects>(CURRENT_PAGE, PAGE_SIZE),
                    bussinessQueryWrapper);
            return pageFilm;
    }



    //找到某一步骤的总数
    @Override
    public Integer findStepNum(Integer step) {
        return projectsMapper.findStepNum(step);
    }


    //通过审核
    @Override
    public void updateProjectStepZero(Integer id) {
        projectsMapper.updateProjectStepZero(id);
    }

    @Override
    public void updateProjectStepZeroThird(Integer id) {
        projectsMapper.updateProjectStepZeroThird(id);
    }

    @Override
    public List<Image> FindCarList(Integer id) {
        return projectsMapper.FindCarList(id);
    }

    @Override
    public List<Image> FindHomeList(Integer id) {
        return projectsMapper.FindHomeList(id);
    }

    @Override
    public List<Image> FindIdCardList(Integer id) {
        return projectsMapper.FindIdCardList(id);
    }

    @Override
    public List<Image> FindOtherList(Integer id) {
        return projectsMapper.FindOtherList(id);
    }

    //提高用户金额
    @Override
    public void updateProjectUserMoneyByUserId(Projects project) {
        projectsMapper.updateProjectUserMoneyByProject(project);
    }


}
